package sy.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * PerOwnerAccesscontrolMapping entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "sys_account_app_equipment_mapping", catalog = "ssh")
public class SysAccountAppEquipmentMapping implements java.io.Serializable {

	// Fields

	private String id;
	private SysAccount sysAccount;
	private AppEquipment appEquipment;
	private String remarks;

	@JsonProperty(value = "sysAccountName")
    private String sysAccountName;
	
	@JsonProperty(value = "appEquipmentName")
    private String appEquipmentName;
	
	@JsonProperty(value = "appEquipmentCode")
    private String appEquipmentCode;

	/** default constructor */
	public SysAccountAppEquipmentMapping() {
	}

	/** full constructor */
	public SysAccountAppEquipmentMapping(SysAccount sysAccount,
			AppEquipment appEquipment, String remarks) {
		this.sysAccount = sysAccount;
		this.appEquipment = appEquipment;
		this.remarks = remarks;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.string")
	@Id
	@Column(name = "id", unique = true, nullable = false, length = 64)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "sysAccount")
	public SysAccount getSysAccount() {
		return sysAccount;
	}

	public void setSysAccount(SysAccount sysAccount) {
		this.sysAccount = sysAccount;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "appEquipment")
	public AppEquipment getAppEquipment() {
		return appEquipment;
	}

	public void setAppEquipment(AppEquipment appEquipment) {
		this.appEquipment = appEquipment;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	@Column(name = "remarks")
	public String getRemarks() {
		return this.remarks;
	}
	
	@Transient
	public String getSysAccountName() {
		return getSysAccount().getName();
	}

	public void setSysAccountName(String sysAccountName) {
		this.sysAccountName = sysAccountName;
	}

	@Transient
	public String getAppEquipmentName() {
		return getAppEquipment().getName();
	}

	public void setAppEquipmentName(String appEquipmentName) {
		this.appEquipmentName = appEquipmentName;
	}

	@Transient
	public String getAppEquipmentCode() {
		return getAppEquipment().getCode();
	}

	public void setAppEquipmentCode(String appEquipmentCode) {
		this.appEquipmentCode = appEquipmentCode;
	}
	
	

}